/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('baasdis', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CreateEenterpriseDIDRequest {
  clientToken?: string(name='ClientToken', description='This parameter is required.', example='01357967-61d1-42a9-8a90-f0dd8a161411'),
  ownerUniqueID?: string(name='OwnerUniqueID', description='This parameter is required.', example='F76iBtCdYuE0DHC33a5amzv3ioUfAqjuBxgek3RwjxBZ2cGP0HDxZy0k8Hs7yNtZRmM3h3KmRn4liSH4gLOOK4P41l'),
}

model CreateEenterpriseDIDResponseBody = {
  DID?: string(name='DID', example='"did:mychain:xxx"'),
  requestId?: string(name='RequestId', example='"7CEDB9B0-E68A-4E67-A258-EEE342695921"'),
  resultCode?: string(name='ResultCode', example='"OK"'),
  resultMessage?: string(name='ResultMessage', example='""'),
  success?: boolean(name='Success', example='true'),
}

model CreateEenterpriseDIDResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateEenterpriseDIDResponseBody(name='body'),
}

/**
 * @param request CreateEenterpriseDIDRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateEenterpriseDIDResponse
 */
async function createEenterpriseDIDWithOptions(request: CreateEenterpriseDIDRequest, runtime: Util.RuntimeOptions): CreateEenterpriseDIDResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clientToken)) {
    body['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.ownerUniqueID)) {
    body['OwnerUniqueID'] = request.ownerUniqueID;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateEenterpriseDID',
    version = '2020-05-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request CreateEenterpriseDIDRequest
 * @return CreateEenterpriseDIDResponse
 */
async function createEenterpriseDID(request: CreateEenterpriseDIDRequest): CreateEenterpriseDIDResponse {
  var runtime = new Util.RuntimeOptions{};
  return createEenterpriseDIDWithOptions(request, runtime);
}

model CreatePersonalDIDRequest {
  clientToken?: string(name='ClientToken', description='This parameter is required.', example='01357967-61d1-42a9-8a90-f0dd8a161411'),
  ownerUniqueID?: string(name='OwnerUniqueID', description='This parameter is required.', example='73BUce7y51BlPFxHucfjdOLC9cdWNnPqc7pyXXJe05c2twjraDPwDm1KhmD6v1d7tUyxjYoNhXLdX18zzp5rsogU87'),
}

model CreatePersonalDIDResponseBody = {
  DID?: string(name='DID', example='"did:mychain:xxx"'),
  requestId?: string(name='RequestId', example='"7C171509-B966-4AD2-B654-7BE14F1F3AA6"'),
  resultCode?: string(name='ResultCode', example='"OK"'),
  resultMessage?: string(name='ResultMessage', example='""'),
  success?: boolean(name='Success', example='true'),
}

model CreatePersonalDIDResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreatePersonalDIDResponseBody(name='body'),
}

/**
 * @param request CreatePersonalDIDRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreatePersonalDIDResponse
 */
async function createPersonalDIDWithOptions(request: CreatePersonalDIDRequest, runtime: Util.RuntimeOptions): CreatePersonalDIDResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clientToken)) {
    body['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.ownerUniqueID)) {
    body['OwnerUniqueID'] = request.ownerUniqueID;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreatePersonalDID',
    version = '2020-05-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request CreatePersonalDIDRequest
 * @return CreatePersonalDIDResponse
 */
async function createPersonalDID(request: CreatePersonalDIDRequest): CreatePersonalDIDResponse {
  var runtime = new Util.RuntimeOptions{};
  return createPersonalDIDWithOptions(request, runtime);
}

model CreateTenantDIDRequest {
  clientToken?: string(name='ClientToken', description='This parameter is required.', example='01357967-61d1-42a9-8a90-f0dd8a161411'),
}

model CreateTenantDIDResponseBody = {
  DID?: string(name='DID', example='"did:mychain:xxx"'),
  requestId?: string(name='RequestId', example='"757DB186-A865-4F65-935D-7D990E0CE451"'),
  resultCode?: string(name='ResultCode', example='"OK"'),
  resultMessage?: string(name='ResultMessage', example='""'),
  success?: boolean(name='Success', example='true'),
}

model CreateTenantDIDResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateTenantDIDResponseBody(name='body'),
}

/**
 * @param request CreateTenantDIDRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateTenantDIDResponse
 */
async function createTenantDIDWithOptions(request: CreateTenantDIDRequest, runtime: Util.RuntimeOptions): CreateTenantDIDResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.clientToken)) {
    body['ClientToken'] = request.clientToken;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateTenantDID',
    version = '2020-05-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request CreateTenantDIDRequest
 * @return CreateTenantDIDResponse
 */
async function createTenantDID(request: CreateTenantDIDRequest): CreateTenantDIDResponse {
  var runtime = new Util.RuntimeOptions{};
  return createTenantDIDWithOptions(request, runtime);
}

model GetDIDRequest {
  DID?: string(name='DID', description='This parameter is required.', example='did:mychain:xxx'),
}

model GetDIDResponseBody = {
  doc?: string(name='Doc', example='"{\\\\"creator\\\\":\\\\"did:mychain:xxx\\\\",\\\\"created\\\\":\\\\"2020-05-22T13:59:49+0800\\\\",\\\\"service\\\\":[],\\\\"index\\\\":[],\\\\"id\\\\":\\\\"did:mychain:xxx\\\\",\\\\"publicKey\\\\":[{\\\\"controller\\\\":\\\\"did:mychain:xxx\\\\",\\\\"id\\\\":\\\\"keys-1\\\\",\\\\"publicKey\\\\":\\\\"xxx\\\\",\\\\"type\\\\":\\\\"Secp256k1VerificationKey2018\\\\"}],\\\\"type\\\\":\\\\"Corporate\\\\",\\\\"@context\\\\":\\\\"https://w3id.org/did/v1\\\\",\\\\"updated\\\\":\\\\"2020-05-22T13:59:49+0800\\\\",\\\\"version\\\\":0,\\\\"authentication\\\\":[\\\\"keys-1\\\\"]}"'),
  requestId?: string(name='RequestId', example='"2C93E421-AD9D-4ABE-B519-6E1ACD18934C"'),
  resultCode?: string(name='ResultCode', example='"OK"'),
  resultMessage?: string(name='ResultMessage', example='”“'),
  success?: boolean(name='Success', example='true'),
}

model GetDIDResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetDIDResponseBody(name='body'),
}

/**
 * @param request GetDIDRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetDIDResponse
 */
async function getDIDWithOptions(request: GetDIDRequest, runtime: Util.RuntimeOptions): GetDIDResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.DID)) {
    body['DID'] = request.DID;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetDID',
    version = '2020-05-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GetDIDRequest
 * @return GetDIDResponse
 */
async function getDID(request: GetDIDRequest): GetDIDResponse {
  var runtime = new Util.RuntimeOptions{};
  return getDIDWithOptions(request, runtime);
}

model IssueNormalVerifiableVCRequest {
  bareClaimStructBody?: [ 
    {
      claim?: string(name='Claim', description='This parameter is required.', example='"test"'),
      claimType?: string(name='ClaimType', example='""'),
    }
  ](name='BareClaimStructBody', description='This parameter is required.'),
  clientToken?: string(name='ClientToken', description='This parameter is required.', example='01357967-61d1-42a9-8a90-f0dd8a161411'),
  expiration?: long(name='Expiration', description='This parameter is required.', example='-1'),
  issuer?: string(name='Issuer', description='This parameter is required.', example='"did:mychain:xxx"'),
  subject?: string(name='Subject', description='This parameter is required.', example='"did:mychain:xxx"'),
}

model IssueNormalVerifiableVCResponseBody = {
  requestId?: string(name='RequestId', example='"4D1E29A7-17D6-48AD-B5AF-F44FAB68D87D"'),
  resultCode?: string(name='ResultCode', example='"OK"'),
  resultMessage?: string(name='ResultMessage', example='""'),
  success?: boolean(name='Success', example='true'),
  verifiableClaimContent?: string(name='VerifiableClaimContent', example='"{\\\\"proof\\\\":{\\\\"type\\\\":\\\\"ecdsa\\\\",\\\\"verificationMethod\\\\":\\\\"did:mychain:xxx#keys-1\\\\",\\\\"signatureValue\\\\":\\\\"xxx\\\\"},\\\\"content\\\\":{\\\\"issuanceDate\\\\":1590127960785,\\\\"subject\\\\":\\\\"did:mychain:xxx\\\\",\\\\"expire\\\\":-1,\\\\"claim\\\\":\\\\"test\\\\",\\\\"id\\\\":\\\\"vc:mychain:xxx\\\\",\\\\"type\\\\":[\\\\"VerifiableCredential\\\\"],\\\\"version\\\\":\\\\"0.7.0\\\\",\\\\"@context\\\\":\\\\"https://www.w3.org/2018/credentials/v1\\\\",\\\\"issuer\\\\":\\\\"did:mychain:xxx\\\\",\\\\"status\\\\":{\\\\"id\\\\":\\\\"vc:mychain:xxx\\\\",\\\\"type\\\\":\\\\"BlockChainStatusList\\\\"}}}"'),
  verifiableClaimId?: string(name='VerifiableClaimId', example='"vc:mychain:xxx"'),
}

model IssueNormalVerifiableVCResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: IssueNormalVerifiableVCResponseBody(name='body'),
}

/**
 * @param request IssueNormalVerifiableVCRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return IssueNormalVerifiableVCResponse
 */
async function issueNormalVerifiableVCWithOptions(request: IssueNormalVerifiableVCRequest, runtime: Util.RuntimeOptions): IssueNormalVerifiableVCResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.bareClaimStructBody)) {
    body['BareClaimStructBody'] = request.bareClaimStructBody;
  }
  if (!Util.isUnset(request.clientToken)) {
    body['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.expiration)) {
    body['Expiration'] = request.expiration;
  }
  if (!Util.isUnset(request.issuer)) {
    body['Issuer'] = request.issuer;
  }
  if (!Util.isUnset(request.subject)) {
    body['Subject'] = request.subject;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'IssueNormalVerifiableVC',
    version = '2020-05-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request IssueNormalVerifiableVCRequest
 * @return IssueNormalVerifiableVCResponse
 */
async function issueNormalVerifiableVC(request: IssueNormalVerifiableVCRequest): IssueNormalVerifiableVCResponse {
  var runtime = new Util.RuntimeOptions{};
  return issueNormalVerifiableVCWithOptions(request, runtime);
}

model UpdateVCRequest {
  issuerDid?: string(name='IssuerDid', description='This parameter is required.', example='"did:mychain:xxx"'),
  VCId?: string(name='VCId', description='This parameter is required.', example='vc:mychain:xxx'),
  VCStatus?: string(name='VCStatus', description='This parameter is required.', example='"1"'),
}

model UpdateVCResponseBody = {
  requestId?: string(name='RequestId', example='"1265B5EA-704A-4DCA-83F9-29C4D3B69549"'),
  resultCode?: string(name='ResultCode', example='"OK"'),
  resultMessage?: string(name='ResultMessage', example='""'),
  success?: boolean(name='Success', example='true'),
}

model UpdateVCResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateVCResponseBody(name='body'),
}

/**
 * @param request UpdateVCRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateVCResponse
 */
async function updateVCWithOptions(request: UpdateVCRequest, runtime: Util.RuntimeOptions): UpdateVCResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.issuerDid)) {
    body['IssuerDid'] = request.issuerDid;
  }
  if (!Util.isUnset(request.VCId)) {
    body['VCId'] = request.VCId;
  }
  if (!Util.isUnset(request.VCStatus)) {
    body['VCStatus'] = request.VCStatus;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateVC',
    version = '2020-05-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request UpdateVCRequest
 * @return UpdateVCResponse
 */
async function updateVC(request: UpdateVCRequest): UpdateVCResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateVCWithOptions(request, runtime);
}

model VerifyVerifiableClaimRequest {
  VCContent?: string(name='VCContent', description='This parameter is required.', example='{"proof": {"type": "ecdsa","verificationMethod": "did:mychain:xxx#keys-1","signatureValue": "xxx"},"content": {"issuanceDate": 1589964299367,"subject": "did:mychain:xxx","expire": -1,"claim": "test01","id": "vc:mychain:xxx","type": ["VerifiableCredential"],"version": "0.7.0","@context": "https://www.w3.org/2018/credentials/v1","issuer": "did:mychain:xxx","status": {"id": "vc:mychain:xxx","type": "BlockChainStatusList"}}}'),
}

model VerifyVerifiableClaimResponseBody = {
  requestId?: string(name='RequestId', example='"EEA284E9-B779-4E62-99EA-E2E8E801A745"'),
  resultCode?: string(name='ResultCode', example='"OK"'),
  resultMessage?: string(name='ResultMessage', example='""'),
  success?: boolean(name='Success', example='true'),
}

model VerifyVerifiableClaimResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: VerifyVerifiableClaimResponseBody(name='body'),
}

/**
 * @param request VerifyVerifiableClaimRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return VerifyVerifiableClaimResponse
 */
async function verifyVerifiableClaimWithOptions(request: VerifyVerifiableClaimRequest, runtime: Util.RuntimeOptions): VerifyVerifiableClaimResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.VCContent)) {
    body['VCContent'] = request.VCContent;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'VerifyVerifiableClaim',
    version = '2020-05-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request VerifyVerifiableClaimRequest
 * @return VerifyVerifiableClaimResponse
 */
async function verifyVerifiableClaim(request: VerifyVerifiableClaimRequest): VerifyVerifiableClaimResponse {
  var runtime = new Util.RuntimeOptions{};
  return verifyVerifiableClaimWithOptions(request, runtime);
}

